<!DOCTYPE html>
<html lang="en">
<head>
  <title>array-selectize</title>
  <meta charset="utf-8"/>
  <script src="../../dist/jsoneditor.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/js/standalone/selectize.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/css/selectize.bootstrap3.css">
</head>
<body>

<h1>Test</h1>
<label for="debug">Value</label>
<textarea id="debug" class="debug" cols="30" rows="10"></textarea>
<button class='get-value'>Get Value</button>
<div class='container'></div>

<script>
  var container = document.querySelector('.container');
  var debug = document.querySelector('.debug');
  var schema = {
    "type": "array",
    "title": "Selectize Arrays",
    "items": {
      "type": "array",
      "format":"selectize",
      "uniqueItems": true,
      "default": ["1", "2"],
      "items": {
        "type": "string",
        "enum": ["1", "2", "3", "4"]
      },
      "options": {
        "selectize": {
            "create": false,
            "plugins": ["remove_button"],
          }
      }
    }
  };

  var editor = new JSONEditor(container, {
    schema: schema
  });

  document.querySelector('.get-value').addEventListener('click', function () {
    debug.value = JSON.stringify(editor.getValue());
  });

</script>

</body>
</html>
